
window.onload = function(){
    console.log(getOneWeekDays())
}

function getOneWeekDays(){
    //还没有写完，年份切换未做
    let arr = [];
    let currentDate = new Date();
    let currentMonth = (new Date()).getMonth() === 0 ? 11 : (new Date()).getMonth();//获取当前月份 （-1 便于计算）
    let currentYear = (new Date()).getYear();//获取当前年份
    let leapMonthDays = isLeapYear(currentYear);//获取每月天数
    let day = (new Date()).getDay() === 0 ? 7 : (new Date()).getDay();//获取星期
    var date = (new Date()).getDate();//获取当前日期
    for(var i = day; i > 0; i--){
        (function(i){
            let j = date--;
            if(j < 1){//取上个月
                j = leapMonthDays[currentMonth - 1] + j;
            }
            arr.unshift(j);
        })(i)
    }
    //重置date
    date = (new Date()).getDate();//获取当前日期
    for(var k = day + 1; k <= 7; k++){
        (function(k){
            let j = ++date;
            if(j > leapMonthDays[currentMonth]){//取下个月
                j = j - leapMonthDays[currentMonth];
            }
            arr.push(j);
        })(k)
    }
    return arr;
}
function isLeapYear(year) {
    let debugs = (year % 4 == 0) && (year % 100 != 0 || year % 400 == 0);
    let leapArr = debugs ? [31,29,31,30,31,30,31,31,30,31,30,31] : [31,28,31,30,31,30,31,31,30,31,30,31];
    return leapArr;
}